class Solution
{
public:
    vector<int> maxSubsequence(vector<int> &nums, int k)
    {
        vector<int> ids(nums.size());
        iota(ids.begin(), ids.end(), 0);
        sort(ids.begin(), ids.end(), [&](int id1, int id2)
             { return nums[id1] > nums[id2]; });
        sort(ids.begin(), ids.begin() + k);
        vector<int> result(k);
        for (int i = 0; i < k; ++i)
        {
            result[i] = nums[ids[i]];
        }
        return result;
    }
};